<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <input type="button" value="添加事件" onclick="addclick()">
    <input type="button" value="移除事件" onclick="removeclick()">
    <p id="pid">点击测试</p>
</body>
<script>

    var pid = document.getElementById('pid');

    function addclick(params) {
        
        console.log('添加')
        pid.addEventListener('click',add)
    }

    function removeclick(params) {
       
        console.log('移除')
        pid.removeEventListener('click',add)
    }

    function add(params) {
        alert('事件添加上了');
    }

</script>
</html>